import React from "react";
import { Link, useRoutes, Outlet } from "react-router-dom";

const Home1 = () => {
  return <div>这是红么页面</div>;
};

const Home = () => {
  return (
    <>
      <div>这是首页</div>
      <Outlet />
    </>
  );
};
const About = () => {
  return <div>这是关于页</div>;
};

const routes = [
  {
    path: "/home",
    element: <Home />,
    children: [
      {
        path: "/home/home1",
        element: <Home1 />,
      },
    ],
  },
  {
    path: "/about",
    element: <About />,
  },
];

const App = () => {
  const element = useRoutes(routes);

  return (
    <>
      <h2>router-v6-路由表</h2>
      <ul>
        <li>
          <Link to="/home">首页</Link>
        </li>
        <li>
          <Link to="/about">关于页</Link>
        </li>
      </ul>

      <hr />

      {element}

      {/* <Routes>
        <Route path="/home" element={<Home />}></Route>
        <Route path="/about" element={<About />}></Route>
      </Routes> */}
    </>
  );
};

export default App;
